package com.wdd.owntool.ui

import android.Manifest
import com.blankj.utilcode.util.ToastUtils
import com.tbruyelle.rxpermissions2.RxPermissions
import com.wdd.libbase.base.BaseActivity
import com.wdd.libbase.util.RxLifecycleUtils
import com.wdd.owntool.R

/**
 *
 * @ProjectName:    OwnTool
 * @Package:        com.wdd.owntool.ui
 * @ClassName:      RxPermissionAcctivity
 * @Description:     rxPermission权限请求
 * @Author:         王丹丹
 * @CreateDate:     2019/12/18 14:03
 * @UpdateUser:     更新者
 * @UpdateDate:     2019/12/18 14:03
 * @UpdateRemark:   更新说明
 * @Version:        1.0
 */
class RxPermissionActivity : BaseActivity() {
    val rxPermission = RxPermissions(this)

    override fun getLayoutId(): Int {
        return R.layout.activity_wang
    }


    override fun initData() {
        if (!rxPermission.isGranted(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
            ToastUtils.showShort("没有文件权限")
        }
        rxPermission.request(Manifest.permission.WRITE_EXTERNAL_STORAGE)
            .`as`(RxLifecycleUtils.bindLifecycle<Boolean>(this))
            .subscribe {
                if (it) {
                    ToastUtils.showShort("权限允许")
                } else {
                    ToastUtils.showShort("权限不允许")
                }
            }

    }
}